const path = require('path');

const devServer = require("./config/devServer.js");
const V5PcPlugin = require('./config/plugin/V5PcPlugin.js');
const V5MPlugin = require('./config/plugin/V5MPlugin.js');
const DistInitPlugin = require('./config/plugin/DistInitPlugin.js');
const DistEndPlugin = require('./config/plugin/DistEndPlugin.js');
const FailedPlugin = require('./config/plugin/FailedPlugin.js');
const DonePlugin = require('./config/plugin/DonePlugin.js');
const MDonePlugin = require('./config/plugin/MDonePlugin.js');
const ShopPlugin = require('./config/plugin/ShopPlugin.js');

const ParamsUtils = require("./config/utils/ParamsUtils.js");
const MPageUtils = require("./config/utils/MPageUtils.js");
const version = new Date().getTime();

let vueConfig = {
    lintOnSave: false, // eslint关闭
    productionSourceMap: false, // map 映射
    assetsDir: "static",
    baseUrl: "./",
    transpileDependencies: ["./src"],
    configureWebpack: {
        plugins: [
            new DistInitPlugin(),
            new DistEndPlugin(),
            new V5MPlugin(),
            // new ShopPlugin({
            //     auto:true
            // }),// 商城插件不能与AutoCompilePlugin同时使用，两边都会重写dist下目录
            new FailedPlugin(),
            new MDonePlugin()
        ],
        resolve: {
            alias: {}
        }
    },
    chainWebpack(config){
        if (process.env.NODE_ENV === 'production') {
            config.plugins.delete('preload-wap');
            config.plugins.delete('preload-native');
            config.plugin('extract-css')
                .tap(args => [{
                    filename: `static/css/[name].css?t=${version}`,
                    chunkFilename: `static/css/[name].css?t=${version}`
                }])
        }
    },
    outputDir: ParamsUtils.getOutputDir(),
    devServer: devServer,
    // pages: MPageUtils.setPages()
};
// 移动端Page创建
MPageUtils.setPages(vueConfig);
module.exports = vueConfig;
